<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>09倒计时</title>
    <style>
        span{
            display: block;
            font-size: 30px;
            color: red;
            text-align: center;
        }
    </style>
    <script>
        window.onload = function(){
            var endTime = new Date("2017-08-31 24:00:00");
            var spanEle = document.getElementsByTagName("span")[0];
            setInterval(clock,1000);  //开启定时器，每秒执行一次
            function clock(){
                var startTime = new Date();
                var minSecond = endTime.getTime()-startTime.getTime();  //得到距离截止时间还有多少毫秒
                var second = parseInt(minSecond/1000);  //得到秒数
                var d = parseInt(second/24/3600);  //得到天数
                var h = parseInt(second/3600%24);  //得到小时
                var m = parseInt(second/60%60);  //得到分钟
                var s = parseInt(second%60);  //得到秒数
                d<10?d="0"+d:d;
                h<10?h="0"+h:h;
                m<10?m="0"+m:m;
                s<10?s="0"+s:s;
                spanEle.innerHTML = "距离活动结束还有"+d+"天"+h+"小时"+m+"分钟"+s+"秒";
            }
        }
    </script>
</head>
<body>
<div>
    <span>
        5634298
    </span>
</div>
</body>
</html>